package org.lvhengchang.schoolmanager.servlet;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lvhengchang.schoolmanager.bean.Teacher;
import org.lvhengchang.schoolmanager.service.TeacherService;
import org.lvhengchang.schoolmanager.service.impl.TeacherServiceImpl;

/**
 * 教师查询处理类
 * 
 * @author LvHengchang
 *
 */
@WebServlet(value = "/teacher/list")
public class TeacherFindAllServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private TeacherService teacherService = new TeacherServiceImpl();

	public TeacherFindAllServlet() {
		super();
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		try {
			List<Teacher> teachers = teacherService.selectByAll();
			req.setAttribute("teachers", teachers);
			req.getRequestDispatcher("/teacher/teacherList.jsp").forward(req, resp);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
